import { IStageAssetsInfo, Stage } from "babylon-lib/base/stage";
import { ArcRotateCamera } from "@babylonjs/core/Cameras/arcRotateCamera";
import { Scene } from "@babylonjs/core/scene";
import { Camera } from "@babylonjs/core/Cameras/camera";
import { Light } from "@babylonjs/core/Lights/light";
import { ILoose } from "babylon-lib/tool/utils";
import { AbstractAssetTaskInfo } from "babylon-lib/loader/asset-task-info";
import * as Data from '../data/data';
import { InitializeHub } from "./components/initialize-hub";


class DefaultStage extends Stage {

    protected assetTaskInfos(): ILoose<AbstractAssetTaskInfo> | Array<IStageAssetsInfo> {
        return Object.assign({}, []) as unknown as ILoose<AbstractAssetTaskInfo>;
    }

    public render(): void {
        this.mainScene.render();
    }

    protected async initializeComponents(scenes: Scene[], cameras: Camera[], lights: Light[]): Promise<void> {

        InitializeHub.initialize(this);

        this.bindData();
        Data.cameraData.reset(true);

    }

    private bindData(): void {
        Data.cameraData.onChange(() => {
            const camera = this.mainCamera as ArcRotateCamera;
            camera.alpha = Data.cameraAlpha.value;
            camera.beta = Data.cameraBeta.value;
            camera.radius = Data.cameraRadius.value;
            camera.target = Data.cameraTarget.value;
        });
    }

}


export { DefaultStage };